package com.xy.blog.capacity.controller;


import com.xy.blog.article.api.model.ArticleQuery;
import com.xy.blog.capacity.remote.ArticleCenterService;
import com.xy.blog.core.springmvc.controller.BaseController;
import com.xy.blog.core.springmvc.result.page.PageReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zanhonglei
 * @version V1.0
 * @Description:
 * @date 2020/5/23
 */
@Api(value = "BlogHomeController",tags = "博客首页")
@RequestMapping("/v1/article")
@RestController
public class HomeController extends BaseController {

    @Autowired
    private ArticleCenterService articleCenterService;


    /**
     * 首页文章
     * @return
     */
    @PostMapping()
    @ApiOperation(value = "分页获取文章", notes = "分页获取文章", httpMethod = "POST")
    public Object articleHomePage(@RequestBody PageReq<ArticleQuery> req){
        return articleCenterService.articleHomePage(req);
    }

    @GetMapping("")
    @ApiOperation(value = "根据Id获取文章", notes = "根据Id获取文章", httpMethod = "GET")
    public Object detail(Long id){
        return articleCenterService.detail(id);
    }

    @GetMapping("/category")
    @ApiOperation(value = "分类专栏", notes = "分类专栏", httpMethod = "GET")
    public Object category(){
        return articleCenterService.getCategory();
    }


    @GetMapping("/pic")
    @ApiOperation(value = "获取图片", notes = "获取图片", httpMethod = "GET")
    public Object pic(Long id) {
        return articleCenterService.getPic(id);
    }


    @GetMapping("/like")
    @ApiOperation(value = "赞", notes = "赞", httpMethod = "GET")
    public Object like(Long id){
        return articleCenterService.like(id);
    }



//    /**
//     * 热点文章
//     * @return
//     */
//    @GetMapping("/hot")
//    @ApiOperation(value = "分页获取文章", notes = "分页获取文章", httpMethod = "GET")
//    public Object hotList(PageReq<ArticleQuery> req){
//        return getPageData(articleServiceImpl.blogHomeArticleList(req));
//    }


}
